package com.xtj.testRabbitMQ;

import com.xtj.RabbitMqDemoApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest(classes = RabbitMqDemoApplication.class)
@RunWith(SpringRunner.class)
public class RabbitMQ {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //第一个模型 helloword
    @Test
    public void testHello(){
        rabbitTemplate.convertAndSend("hello","你好，世界！！");
    }

    //work工作队列
    @Test
    public void testWork(){
        rabbitTemplate.convertAndSend("work","你好，work模型！！");
    }
    //广播模式 fanout
    @Test
    public void testFanout(){
        rabbitTemplate.convertAndSend("logs","","Fanout的模型发生的消息");
    }
    //路由模式 route
    @Test
    public void testRoute(){
        rabbitTemplate.convertAndSend("directs","info","info的key的模型发生的路由信息消息");
    }
    //动态路由模式 topic
    @Test
    public void testTopic(){
        rabbitTemplate.convertAndSend("topics","user.save","user.save的模型发生的动态路由信息消息");
    }
}
